import { mul } from './test';
import '../css/index.css';

function sum(...args) {
  return args.reduce((p, c) => p + c, 0);
}
// eslint-disable-next-line
console.log(mul(1, 2))
// eslint-disable-next-line
console.log(sum(1, 2, 3, 4));

// 注册 serviceWorker
// 处理兼容性问题
/*
  sw 必须运行在服务器上
  -- nodejs
    yarn add serve --dev
    server -s build 启动服务器，将build目录下所有资源作为静态资源暴露出去

  -- nginx

 */
if ('serviceWorker' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/service-worker.js')
      .then(() => {
        // eslint-disable-next-line
        console.log('sw 注册成功了');
      }).catch(() => {
        // eslint-disable-next-line
        console.log('sw 注册失败失败了');
      });
  });
} else {
  // eslint-disable-next-line
  console.log('sw nothing');
}
